package ru.simplemaps.osmapi;

import ru.simplemaps.osmapi.objects.Node;
import ru.simplemaps.osmapi.objects.Relation;
import ru.simplemaps.osmapi.objects.Way;

import java.util.HashMap;
import java.util.Map;

/**
 * Represents parsed OSM data
 *
 * @author enaku_adm
 * @since 22.07.2010 11:23:43
 */
public class OSMData {
    public final Map<Long, Node> nodes;
    public final Map<Long, Way> ways;
    public final Map<Long, Relation> relations;

    public OSMData() {
        nodes = new HashMap<Long, Node>();
        ways = new HashMap<Long, Way>();
        relations = new HashMap<Long, Relation>();
    }

    public OSMData(Map<Long, Node> nodes, Map<Long, Way> ways, Map<Long, Relation> relations) {
        this.nodes = nodes;
        this.relations = relations;
        this.ways = ways;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        OSMData data = (OSMData) o;

        if (!nodes.equals(data.nodes)) return false;
        if (!relations.equals(data.relations)) return false;
        if (!ways.equals(data.ways)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = nodes.hashCode();
        result = 31 * result + ways.hashCode();
        result = 31 * result + relations.hashCode();
        return result;
    }
}
